package com.vincent.filepicker.filter.loader;

import ohos.aafwk.ability.DataAbilityHelper;
import ohos.aafwk.ability.DataAbilityRemoteException;
import ohos.app.Context;
import ohos.data.dataability.DataAbilityPredicates;
import ohos.data.resultset.ResultSet;
import ohos.media.photokit.metadata.AVStorage;


/**
 * Created by Vincent Woo
 * Date: 2016/10/11
 * Time: 17:35
 */

public class AudioLoader {
    private ResultSet mResultSet;
    private static final String[] AUDIO_PROJECTION = {
            //Base File
            AVStorage.Audio.Media.ID,
            AVStorage.Audio.Media.TITLE,
            AVStorage.Audio.Media.DATA,
            AVStorage.Audio.Media.SIZE,
            AVStorage.Audio.Media.DATE_ADDED,
            //Audio File
            AVStorage.Audio.Media.DURATION
    };

    public AudioLoader(Context context) {
        DataAbilityPredicates dataAbilityPredicates = new DataAbilityPredicates();
        dataAbilityPredicates.setOrder(AVStorage.Images.Media.DATE_ADDED + " desc");
        try {
            mResultSet = DataAbilityHelper.creator(context)
                    .query(AVStorage.Audio.Media.EXTERNAL_DATA_ABILITY_URI,
                            AUDIO_PROJECTION, null);
        } catch (DataAbilityRemoteException e) {
            e.printStackTrace();
        }
    }

    public ResultSet getResultSet() {
        return mResultSet;
    }
}
